<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>上传论文</title>
    <#include "layout/import_js.ftl" />
    <#include "layout/import_css.ftl" />
    <script>
    $(()=>{
        $("#add-thesis").on('click',function(){
            let form = new FormData(document.getElementById("form-thesis"));
            $.ajax({
                url: '/thesis/add',
                method: 'post',
                data:form,
                processData: false, //禁止序列化data，默认为true
                contentType: false, //避免JQuery对contentType做操作
                success: function (res) {
                    if (res.code == 0) {
                        $('#alertModal').modal('show');
                    } else {
                        console.log(res);
                    }
                },
                error: function (err) {
                    console.log(err);
                }
            })
        })
         
    })
    </script>
</head>
<body>
    <#include "layout/header.ftl"/>
    <#include "layout/sidebar.ftl"/>

    <div class="container">
        <div class="raw">
            <div class="col-sm-6 col-sm-offset-3">
                <form action="/thesis/add" id="form-thesis" method="POST" enctype="multipart/form-data" class="form-horizontal">
                    <div class="form-group">
                        <label>编号</label>
                        <input type="text" class="form-control" value="test" name="number" placeholder=" ">
                    </div>
                    <div class="form-group">
                        <label>名称</label>
                        <input type="text" class="form-control" value="test" name="name" placeholder=" ">
                    </div>
                    <div class="form-group">
                        <label>摘要</label>
                        <textarea name="summary" class="form-control" rows="6"></textarea>
                    </div>
                    <div class="form-group">
                        <label>作者</label>
                        <input type="text" class="form-control" value="test" name="authors" placeholder=" ">
                    </div>
                    <div class="form-group">
                        <label>导师</label>
                        <input type="text" class="form-control" value="test" name="mentors" placeholder=" ">
                    </div>
                    <div class="form-group">
                        <label>发表日期</label>
                        <input type="date" class="form-control" value="2018-01-01" name="publishDate">
                    </div>
                    <div class="form-group jumbotron">
                        <label>论文类型</label>
                        <select name="thesisTypeId" class="form-control">
                            <#list thesisTypes as i>
                                <option value="${i.id!}">${i.name!}</option>
                            </#list>
                        </select>
                        <label for="">编号</label>
                        <input type="text" class="form-control" name="thesisTypeName" value="test" placeholder="">
                    </div>
                    <div class="form-group jumbotron">
                        <label>论文发表类型</label>
                        <select name="thesisPublishTypeId" class="form-control">
                            <#list thesisPublishTypes as i>
                                <option value="${i.id!}">${i.name!}</option>
                            </#list>
                        </select>
                        <label for="">发表类型名</label>
                        <input type="text" class="form-control" name="thesisPublishTypeContent" value="test" placeholder="">
                    </div>
                    <div class="form-group">
                        <label for="exampleInputFile">上传文件</label>
                        <input type="file" name="file" id="exampleInputFile">
                        <p class="help-block">支持pdf、word、excel、png、jpeg等类型</p>
                    </div>
                    
                    <div class="form-group">
                        <div class="col-sm-6 col-sm-offset-3">
                            <button type="button" class="btn btn-success" id="add-thesis" class="btn btn-success">保存</button>
                            <button class="btn btn-info">取消</button>
                            <button type="reset" class="btn btn-warning">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <#include "layout/alert.ftl"/>
    <#include "layout/footer.ftl"/>
</body>
</html>